#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 1e5 + 10;
int n, a[N];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int res = a[0];
    for (int i = 2; i <= n; i++) {
        if (a[i] > res) res = a[i];
        else break;
    }
    cout << res << endl;
    return 0;
}